package com.bzg.baseSpringComponent.environment;

import com.bzg.baseSpringComponent.messagesource.Config;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.MutablePropertySources;

import java.util.Map;

/**
 * applicationContext 实现了EnvironmentCapable，具有操作环境实例的功能
 * */
public class EnvironmentStyle {

	public static void main(String[] args) {
		AnnotationConfigApplicationContext annotationConfigApplicationContext = new AnnotationConfigApplicationContext(Config.class);
		// SystemEnvironment,为操作系统的环境，如：java.class.path = ''
		Map<String, Object> systemEnvironment = annotationConfigApplicationContext.getEnvironment().getSystemEnvironment();
		// SystemProperties 为java运行时指定的参数。java -jar -Dtest=''
		Map<String, Object> systemProperties = annotationConfigApplicationContext.getEnvironment().getSystemProperties();
		// PropertySources 为程序内部的属性资源，也就是properties文件中的key-value
		MutablePropertySources propertySources = annotationConfigApplicationContext.getEnvironment().getPropertySources();
		//以上三种环境值，都在Environment实例中

	}
}
